package conf

import (
	"app/cache"
	"app/model"

	"gopkg.in/ini.v1"
)

var (
	AppMode     string
	HttpPort    string
	JwtSecret   string
	TokenExpire int
)

// 初始化系统配置
func Init() {
	file, err := ini.Load("conf/app.ini")
	if err != nil {
		panic(err)
	}
	if err := LoadLocales("conf/locales/zh-cn.yaml"); err != nil {
		panic(err)
	}

	AppMode = file.Section("server").Key("AppMode").String()
	HttpPort = file.Section("server").Key("HttpPort").String()
	JwtSecret = file.Section("jwt").Key("JwtSecret").String()
	TokenExpire = file.Section("jwt").Key("TokenExpire").MustInt(604800)

	model.Init(file)
	cache.Init(file)
}
